package com.zy.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zy.Vo.HousedVo;
import com.zy.Vo.PageHousedVO;
import com.zy.mapper.HousedMapper;
import com.zy.pojo.Housed;
import com.zy.pojo.Inbound;
import com.zy.service.HousedService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.List;
@Service("hosedService")
public class HousedServiceImpl implements HousedService {
    @Resource
    private HousedMapper housedMapper;
    @Override
    public PageHousedVO getPageHousedList(Integer pageSize, Integer pageNo, HousedVo housedVo) {
        Page page = new Page();
        page.setSize(pageSize);
        page.setCurrent(pageNo);
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.like(!StringUtils.isEmpty(housedVo.getHousedName()),"housed_Name",housedVo.getHousedName())
                .like(!StringUtils.isEmpty(housedVo.getHousedId()),"housed_id",housedVo.getHousedId())
                .like(!StringUtils.isEmpty(housedVo.getHousedNumber()),"housed_number",housedVo.getHousedNumber())
                .like(!StringUtils.isEmpty(housedVo.getHousedUnitPrice()),"housed_UnitPrice",housedVo.getHousedUnitPrice())
                .like(!StringUtils.isEmpty(housedVo.getHousedTotalPrice()),"housed_TotalPrice",housedVo.getHousedTotalPrice());
        //housed_date
        List<Housed> list = housedMapper.getHousedPageList(page,queryWrapper);
        System.out.println(page.getTotal()+"+++++++++++++++++++++++++");
        return new PageHousedVO(list,page.getTotal());
    }

    @Override
    public List<Housed> getHousedList() {
        return housedMapper.selectList(null);
    }

    @Override
    public void HousedAdd(Housed housed) {
        Inbound inbound = new Inbound();
        housedMapper.getHoused(housed);
    }

    @Override
    public void HousedDelete(Integer id) {
        housedMapper.deleteById(id);
    }
}
